import { fetchCategory } from '@/api/home'

export default {
  namespaced: true, // 命名空间
  state: () => ({
    categoryList: []
  }),
  mutations: {
    // 设置导航列表
    setCategoryList (state, dataArr) {
      state.categoryList = dataArr
    }
  },
  actions: {
    // 调接口获取数据
    async getCategoryList ({ commit }) {
      const res = await fetchCategory()
      commit('setCategoryList', res.result)
    }
  }

}
